import * as echarts from 'echarts';
import { useEffect, useRef } from 'react';

const Echarts=({title})=>{
  const echartsRef=useRef(null)
  useEffect(()=>{
const chartDom = echartsRef.current;
const myChart = echarts.init(chartDom);
const option= {
  title:{
    text:title
  },
  xAxis: {
    type: 'category',
    data: ['Vue','React','Angular']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [300,400,100],
      type: 'bar'
    }
  ]
};
option && myChart.setOption(option);

  })
  return (
    <div ref={echartsRef} style={{width:'500px',height:'400px'}}></div>
  )
}

export default Echarts